import { requestClient } from './request';

interface QrcodeForm {
  appId?: string;
  autoColor: boolean;
  envVersion?: string;
  isHyaline: boolean;
  lineColor?: {
    [property: string]: any;
    key?: string;
  };
  path: string;
  width: number;

  [property: string]: any;
}

/**
 * 生成小程序码
 * @param data
 */
export function generateWechatQrCode(data: QrcodeForm) {
  return requestClient.post<string>('/wx/ma/generateCode', data);
}

interface UrlLinkForm {
  cloud_base?: {
    [property: string]: any;
    domain?: string;
    env?: string;
    path?: string;
    query?: string;
    resource_appid?: string;
  };
  env_version?: string;
  expire_interval?: number;
  expire_time?: number;
  expire_type?: number;
  is_expire?: boolean;
  path?: string;
  query?: string;

  [property: string]: any;
}

/**
 * 生成小程序短链
 * @param data
 */
export function generateWechatUrlLink(data: UrlLinkForm) {
  return requestClient.post<string>('/wx/ma/generateUrlLink', data);
}
